package tour.spring.bc.model;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;

@Entity
public class Hotel {

	private Long id;
	private Place place;
	private String name;
	private List<Image> images;

//	@Any(metaColumn = @Column(name = "place_type"), fetch = FetchType.LAZY)
//	@AnyMetaDef(idType = "long", metaType = "string", metaValues = {
//			@MetaValue(value = "C", targetEntity = City.class),
//			@MetaValue(value = "R", targetEntity = Region.class) })
//	@Cascade({ org.hibernate.annotations.CascadeType.ALL })
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinColumn(name = "place_id")
	public Place getPlace() {
		return place;
	}

	public void setPlace(Place place) {
		this.place = place;
	}

	@Column
	@Id
	@SequenceGenerator(name="hotel_seq", sequenceName="hotel_seq")
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="hotel_seq")
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

    @OneToMany(cascade=CascadeType.ALL)
    @JoinColumn(name="hotel_id")
	public List<Image> getImages() {
		return images;
	}

	public void setImages(List<Image> images) {
		this.images = images;
	}
	
	

}
